/* Responsive Markdown Editor Styles */
.responsive-markdown-editor {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #fff;
  position: relative;
}

/* 桌面端侧边栏 */
.desktop-sidebar-right {
  position: fixed;
  top: 64px;
  right: 0;
  width: 320px;
  height: calc(100vh - 64px);
  background: #fff;
  border-left: 1px solid #f0f0f0;
  overflow-y: auto;
  z-index: 50;
}

.desktop-optimization-section {
  /* 优化面板在桌面端作为内联内容 */
  padding: 16px;
}

/* Mobile Header */
.mobile-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
}

/* Desktop Layout */
.desktop-editor-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  height: calc(100vh - 64px);
  margin-right: 0; /* 为侧边栏留出空间 */
}

/* 当有侧边栏时调整布局 */
.responsive-markdown-editor:has(.desktop-sidebar-right) .desktop-editor-layout {
  margin-right: 320px;
}

.editor-column,
.preview-column {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.editor-column {
  border-right: 1px solid #f0f0f0;
}

.preview-header {
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  background: #fafafa;
}

.preview-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #262626;
}

/* Markdown Editor */
.markdown-editor {
  flex: 1;
  width: 100%;
  padding: 16px;
  border: none;
  outline: none;
  resize: none;
  font-family: 'Monaco', 'Consolas', 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.5;
  background: #fff;
  overflow-y: auto;
}

/* 优化占位符 */
.optimization-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: calc(100vh - 200px);
  padding: 24px;
}

.optimization-placeholder.mobile {
  height: calc(100vh - 180px);
}

.markdown-editor.mobile {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 16px !important; /* Prevent iOS auto-zoom */
  line-height: 1.7;
  padding: 16px;
  height: calc(100vh - 120px - 60px); /* header + toolbar */
}

.markdown-editor::placeholder {
  color: #bfbfbf;
}

.markdown-editor:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
  opacity: 0.6;
}

/* Preview Pane */
.preview-pane {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  background: #fff;
}

.preview-pane.mobile {
  padding: 16px;
  font-size: 16px;
  line-height: 1.7;
  height: calc(100vh - 120px); /* header + tabs */
}

/* Mobile Tabs */
.mobile-editor-tabs {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mobile-editor-tabs .ant-tabs {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.mobile-editor-tabs .ant-tabs-content {
  flex: 1;
  height: 0;
}

.mobile-editor-tabs .ant-tabs-tabpane {
  height: 100%;
  overflow-y: auto;
}

/* Optimization Pane */
.optimization-pane {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.optimization-pane.mobile {
  padding: 12px;
  height: calc(100vh - 120px);
}

/* Touch-friendly elements */
.h-touch {
  min-height: 44px !important;
}

.w-touch {
  min-width: 44px !important;
}

/* Mobile styles */
@media (max-width: 767px) {
  .responsive-markdown-editor {
    position: relative;
  }

  .mobile-editor-header {
    padding: 8px 12px;
  }

  .markdown-editor {
    -webkit-tap-highlight-color: transparent;
  }

  /* Safe area for devices with notch */
  .mobile-editor-header {
    padding-top: max(12px, env(safe-area-inset-top));
  }
}

/* Tablet styles */
@media (min-width: 768px) and (max-width: 1024px) {
  .desktop-editor-layout {
    grid-template-columns: 1.2fr 1fr;
  }

  .markdown-editor {
    font-size: 15px;
  }
}

/* Desktop styles */
@media (min-width: 1025px) {
  .desktop-editor-layout {
    grid-template-columns: 1fr 1fr;
  }

  .preview-pane {
    padding: 32px;
  }
}

/* Smooth transitions */
.markdown-editor,
.preview-pane,
.optimization-pane {
  transition: all 0.3s ease;
}

/* Scrollbar styling */
.markdown-editor::-webkit-scrollbar,
.preview-pane::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.markdown-editor::-webkit-scrollbar-track,
.preview-pane::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.markdown-editor::-webkit-scrollbar-thumb,
.preview-pane::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

.markdown-editor::-webkit-scrollbar-thumb:hover,
.preview-pane::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Mobile - hide scrollbar */
@media (max-width: 767px) {
  .markdown-editor::-webkit-scrollbar,
  .preview-pane::-webkit-scrollbar {
    display: none;
  }

  .markdown-editor,
  .preview-pane {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
}
